
/// 分页数据实体
class PageEntity<T> {
  int curPage;
  List<T> list;
  int offset;
  bool over;
  int pageCount;
  int size;
  int total;

  PageEntity({
    required this.curPage,
    required this.list,
    required this.offset,
    required this.over,
    required this.pageCount,
    required this.size,
    required this.total,
  });

  factory PageEntity.fromJson(
      Map<String, dynamic> json,
      T Function(dynamic itemJson) fromJsonT,
      ) {
    return PageEntity<T>(
      curPage: json['curPage'],
      list: List<T>.from(json['datas'].map(fromJsonT)),
      offset: json['offset'],
      over: json['over'],
      pageCount: json['pageCount'],
      size: json['size'],
      total: json['total'],
    );
  }

  Map<String, dynamic> toJson(Object Function(T value) toJsonT) {
    return {
      'curPage': curPage,
      'datas': list.map(toJsonT).toList(),
      'offset': offset,
      'over': over,
      'pageCount': pageCount,
      'size': size,
      'total': total,
    };
  }
}